pub const DEFAULT_RAISE_AND_DEMERIT_AMOUNT: i32 = 1000;

const DEFAULT_STARTING_SALARY: i32 = 30000;

#[derive(Default)]
pub struct Employee {
    first_name: String,
    last_name: String,
    employee_number: i32,
    salary: i32,
    hired: bool,
}

impl Employee {
    pub fn new(first_name: String, last_name: String) -> Employee {
        Employee {
            first_name,
            last_name,
            employee_number: -1,
            hired: false,
            salary: DEFAULT_STARTING_SALARY,
        }
    }

    pub fn promote(&mut self, raise_amount: i32) {
        self.set_salary(self.get_salary() + raise_amount);
    }

    pub fn demote(&mut self, demerit_amount: i32) {
        self.set_salary(self.get_salary() - demerit_amount);
    }

    pub fn hire(&mut self) {
        self.hired = true;
    }

    pub fn fire(&mut self) {
        self.hired = false;
    }

    pub fn display(&self) {
        println!(
            "Employee:{}·{}",
            self.get_last_name(),
            self.get_first_name()
        );
        println!("-------------");
        println!(
            "{} Employee",
            if self.is_hired() { "Current" } else { "Former" }
        );
        println!("Employee Number:{}", self.get_employee_number());
        println!("Salary:${}", self.get_salary());
    }

    pub fn set_first_name(&mut self, first_name: String) {
        self.first_name = first_name;
    }

    pub fn get_first_name(&self) -> &str {
        &self.first_name
    }

    pub fn set_last_name(&mut self, last_name: String) {
        self.last_name = last_name;
    }

    pub fn get_last_name(&self) -> &str {
        &self.last_name
    }

    pub fn set_employee_number(&mut self, employee_number: i32) {
        self.employee_number = employee_number;
    }

    pub fn get_employee_number(&self) -> i32 {
        self.employee_number
    }

    pub fn get_salary(&self) -> i32 {
        self.salary
    }

    pub fn set_salary(&mut self, new_salary: i32) {
        self.salary = new_salary;
    }

    pub fn is_hired(&self) -> bool {
        self.hired
    }
}
